/* eslint-disable vue/no-parsing-error */
/* eslint-disable vue/html-quotes */
<template>
  <div class="header">
    <div class="section">
      <div class="con1">
        <div class="imgBox">
          <img :src="headerObj.logoImg" alt="logo" @click="goHome">
        </div>
        <div class="search-container">
          <div class="search-box">
            <div class="serch-left">
              <!-- <input v-model="searchData" type="search" :placeholder="'大家都在搜：'+ hotWord.slice(0,3).toString()" max="10"> -->
              <i class="iconfont iconindex_icon_sousuo" />
              <input v-model="searchData" type="search" placeholder="请输入您要搜索的内容" max="10">
            </div>
            <el-button type="primary" icon="el-icon-search" class="search-button" @click="goList">搜索</el-button>
          </div>
          <ul>
            <li v-for="(item,index) in hotWord" :key="index" @click="hotSearch(item)">{{ item }}</li>
          </ul>
        </div>

        <div v-if="loginBool" class="user login-box">
          <div class="news-box" @click="userMsg">
            <i class="iconfont iconindex_icon_bell" />
            <span>2</span>
          </div>
          <span>|</span>
          <img src="../../../assets/img/user/user.png">
          <span class="userCenter" @click="toUser">个人中心</span>
          <span>|</span>
          <span class="out" @click="out">退出</span>
        </div>
        <div v-else class="user user-self">
          <el-button size="small" @click="login">登录</el-button>
          <el-button type="primary" size="small" @click="register">注册</el-button>
        </div>
      </div>
      <div class="nav-box">
        <ul class="tab-switch-box">
          <router-link v-for="(item,index) in navList1" :key="index" tag="li" :to="{path:theRouter[index]}" :exact="index==0?true:false">
            {{ item.name }}
            <div v-if="item.childs" class="liChild">
              <router-link v-for="(cItem,cIndex) in item.childs" :key="cIndex" tag="p" :to="{path:routerChilds[cIndex]}">{{ cItem }}</router-link>
              <!-- <p v-for="(cItem,cIndex) in item.childs" :key="cIndex" @click="goTo(index)">{{ cItem }}</p> -->
            </div>
          </router-link>
        </ul>
        <span>|</span>
        <p>
          <span>服务热线：</span>
          <span>400-622-888</span>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
// import {mapState} from "vuex"
export default {
  props: {
    headerObj: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      /* header */
      hax: true,
      choseBool: true,
      theRouter: ['/vMain', '/brand', '/vMain/allBrand', '/vMain/join', '/vMain/strength', '/vMain/news', '/vMain/about'],
      routerChilds: ['/vMain/allBrand/tuijian', '/vMain/allBrand'],
      navList1: [
        {
          name: '首页',
          childs: null
        },
        {
          name: '十大品牌',
          childs: null
        },
        {
          name: '品牌大全',
          childs: ['品牌推荐', '品牌大全']
        },
        {
          name: '招商加盟',
          childs: null
        },
        {
          name: '榜上力量',
          childs: null
        },
        {
          name: '新闻资讯',
          childs: null
        },
        {
          name: '关于我们',
          childs: null
        }
      ],
      hotWord: ['回力', '三叶草', '乔丹', '匡威', '李宁', '阿迪达斯'],
      searchData: ''
    }
  },
  /* computed:mapState({
    dddd:state => state.upLogin
      //console.log(this.$store.state.template1.upLogin,123)
  }), */
  computed: {
    loginBool() {
      return this.$store.state.template1.upLogin
    }
  },
  created() {

  },
  methods: {
    login() {
      this.$router.push('/login')
    },
    register() {
      this.$router.push('/register')
    },
    goList() {
      this.$router.push({ path: '/vMain/searchList', query: { hasMsg: this.searchData }})
    },
    hotSearch(item) {
      this.searchData = item
      this.$router.push({ path: '/vMain/searchList', query: { hasMsg: this.searchData }})
    },
    out() {
      this.$store.commit('template1/changeLogin', false)
    },
    toUser() {
      this.$router.push('/vMain/newpersonage')
    },
    userMsg() {
      this.$router.push('/vMain/newpersonage/msg')
    },
    goHome() {
      this.$router.push('/vMain')
    },
    goTo(num) {
      console.log(num, 11111)
      // this.$router.push(this.routerChilds[num])
    }
  }

}
</script>

<style lang="scss" scoped>
.header{
  height: 143px;
  width: 100%;
  min-width: 1200px;
  border-bottom: 1px solid #ccc;
  background-color: #fff;
  >.section{
    width: 1200px;
    margin: 0 auto;
    padding-top: 26px;
    >.con1{
      width: 100%;
      height: 69px;
      color: #333;
      font-size: 12px;
      /* &::after{
        display:block;clear:both;content:"";visibility:hidden;height:0
      } */
      >.imgBox{
        float: left;
        height: 69px;
        line-height: 69px;
        width: 182px;
        vertical-align: middle;
        >img{
          margin-right: 28px;
          max-height: 69px;
          max-width: 182px;
          cursor: pointer;
        }

      }
      >.search-container{
        float: left;
        height: 69px;
        margin-left: 241px;
        >.search-box{
          width: 533px;
          height: 38px;
          display: flex;
          flex-flow: row nowrap;
          justify-content: flex-start;
          align-items: center;
          margin-bottom: 12px;
          color: #666;
          >.serch-left{
            height: 38px;
            display: flex;
            flex-flow: row nowrap;
            justify-content: flex-start;
            align-items: center;
            border: 1px solid #EBEBEB;
            >i{
              padding-left: 14px;
              font-size: 17px;
            }

            >input{
              border: none;
              width: 354px;
              padding-left: 11px;
            }
            input::-webkit-input-placeholder {
              /* 修改placeholder颜色  */
              color: #ccc;
              font-size: 12px;
            }
          }
          >.search-button{
            color: #666;
            background-color: #EBEBEB;
            border: none;
            border-radius: 0;
            border-top-right-radius: 5px;
            border-bottom-right-radius: 5px;
            width: 90px;
          }
        }
        >ul{
          font-size: 14px;
          color: #BEBCBC;
          padding-left: 20px;
          display: flex;
          flex-flow: row nowrap;
          justify-content: flex-start;
          align-items: center;
          >li{
            margin-right: 20px;
            cursor: pointer;
          }
          >li:nth-child(2){
            color: #417AEF;
          }
        }
      }
      >.user{
        float: right;
        width: 194px;
        height: 28px;
        display: flex;
        flex-flow: row nowrap;
        justify-content: space-between;
        align-items: center;
        >.userCenter{
          cursor: pointer;
        }
        >.out{
          cursor: pointer;
        }
      }
      >.login-box{
        padding-top: 11px;
        >.news-box{
          position: relative;
          cursor: pointer;
          >i{
            font-size: 25px;
          }
          >span{
            display: block;
            width: 18px;
            height: 18px;
            line-height: 18px;
            border-radius: 50%;
            text-align: center;
            background-color: #417AEF;
            color: #fff;
            position: absolute;
            top: -5px;
            right: -4px;
          }

        }
      }
      .user-self{
        padding-top: 13px;
        font-size: 12px;
        display: flex;
        flex-flow: row nowrap;
        justify-content: flex-end;
      }
    }
    >.nav-box{
      width: 1200px;
      margin: 0 auto;
      display: flex;
      flex-flow: row nowrap;
      justify-content: space-between;
      align-items: center;
      >.tab-switch-box{
        width: 776px;
        display: flex;
        flex-flow: row nowrap;
        justify-content: space-between;
        align-items: center;
        font-size: 16px;
        >li{
          position: relative;
          height: 47px;
          line-height: 47px;
          cursor: pointer;
          >.liChild{
            display: none;
            position: absolute;
            bottom: -101px;
            left: 0;
            z-index: 99;
            width: 100px;
            padding: 16px 0;
            background-color: #fff;
            //background-color: rgb(107, 194, 197);
            font-size: 14px;
            color: #333;
            >p{
              text-align: center;
              height: 34px;
              line-height: 34px;
            }
            >p:hover{
              background-color: #417AEF;
              color: #fff;
            }
          }
        }
        >li:hover{
          >.liChild{
            display: block;
          }
        }
        >.router-link-exact-active{
          color: #417AEF;
          &::after{
            display:block;
            content:"";
            width: 100%;
            height:2px;
            background-color: #417AEF;
            position: absolute;
            bottom: -1px;
            left: 0;
            z-index: 99;
          }
        }
        >.router-link-active{
          color: #417AEF;
          &::after{
            display:block;
            content:"";
            width: 100%;
            height:2px;
            background-color: #417AEF;
            position: absolute;
            bottom: -1px;
            left: 0;
            z-index: 99;
          }
        }
      }
      >span{
        color: #EBEBEB;
      }
      >p{
        height: 46px;
        display: flex;
        flex-flow: row nowrap;
        justify-content: flex-start;
        align-items: center;
        >span{
          line-height: 1;
          display: block;
        }
        >span:first-child{
          font-size: 20px;
          color: #666;
        }
        >span:last-child{
          font-size: 30px;
          color: #417AEF;
          padding-top: 3px;
        }
      }
    }
  }
}
</style>

